//
//  SXSearchBar.m
//  Weibo1
//
//  Created by dfpo on 15/2/14.
//  Copyright (c) 2015年 dfpo. All rights reserved.
//

#import "SXSearchBar.h"

@implementation SXSearchBar
- (id)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        // 让内容垂直居中
        self.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        
        self.font = [UIFont systemFontOfSize:15];
        self.placeholder = @"请输入搜索条件";
        self.background = [UIImage imageNamed:@"searchbar_textfield_background"];
        // 放大镜
        UIImageView *imageView = [[UIImageView alloc] init];
        imageView.image = [UIImage imageNamed:@"searchbar_textfield_search_icon"];
        imageView.width = 30;
        imageView.height = 30;
        imageView.contentMode = UIViewContentModeCenter;
        self.leftView = imageView;
        // 让我们设置这个放大镜的UIImageView一直显现
        self.leftViewMode = UITextFieldViewModeAlways;
        // 让全部清除按钮一直显现
        self.clearButtonMode = UITextFieldViewModeAlways;
    }
    

    return self;
}

+ (instancetype)searchBar {
    
    return [[self alloc] init];
}
@end
